package compareequals;

import java.util.ArrayList;
import java.util.HashSet;

import org.junit.Test;

public class EqualsTest {
	@Test
	public void list() {
		ArrayList<Person> al = new ArrayList<>();
		al.add(new Person(14));
		al.add(new Person(11));
		al.add(new Person(12));
		al.add(new Person(13));
		
		// 为什么重写equals？？？根据对象属性判断
//		boolean contains = al.contains(new Person(14));
//		System.out.println(contains);
		
//		int indexOf = al.indexOf(new Person(15));
//		System.out.println(indexOf);
		
//		int indexOf2 = al.lastIndexOf(new Person(15));
//		System.out.println(indexOf2);
		
//		boolean remove = al.remove(new Person(11));
		
	}
	
	@Test
	public void set() {
		HashSet<Person> al = new HashSet<>();
		al.add(new Person(11));
		al.add(new Person(12));
		al.add(new Person(14));
		al.add(new Person(13));
		System.out.println("-------------------");
		// 为什么重写equals？？？根据对象属性判断
//		boolean contains = al.contains(new Person(14));
//		System.out.println(contains);
	
		boolean remove = al.remove(new Person(11));
		
	}
}
